
    /**  
    * @Title: PortalCustomDefController.java
    * @Package com.efast.cafe.portal.controller.company
    * @Description: TODO(用一句话描述该文件做什么)
    * @author Administrator
    * @date 2019年1月18日
    * @version V1.0  
    */
    
package com.efast.cafe.portal.controller.company;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.cafe.framework.enums.ResultStatus;
import com.efast.cafe.portal.entity.company.PortalCustomDef;
import com.efast.cafe.portal.service.company.PortalCustomDefService;
import com.efast.cafe.util.StringUtil;

/**
    * @ClassName: PortalCustomDefController
    * @Description: TODO(这里用一句话描述这个类的作用)
    * @author Administrator
    * @date 2019年1月18日
    *
    */
@Controller
@RequestMapping("/company")
public class PortalCustomDefController {

	@Autowired
	private PortalCustomDefService portalCustomDefService;
	
	@RequestMapping(value = "/custom/def",method= RequestMethod.POST)
	public @ResponseBody ResultBean customDefByUser(@RequestBody PortalCustomDef def){
		ResultBean res = new ResultBean(true);
		if(StringUtil.isEmpty(def.getDefKey())){
			res.setSuccess(false);
			res.setErrorCode(ResultStatus.PARAM_ERROR.getCode());
			return res;
		}
		portalCustomDefService.customDefByUser(def);
		return res;
	}
	
	@RequestMapping(value = "/custom/defQuery",method= RequestMethod.POST)
	public @ResponseBody ResultBean customDefQueryByUser(@RequestBody PortalCustomDef def){
		ResultBean res = new ResultBean(true);
		if(StringUtil.isEmpty(def.getDefKey()) && StringUtil.isEmpty(def.getDefGroup())){
			res.setSuccess(false);
			res.setErrorCode(ResultStatus.PARAM_ERROR.getCode());
			return res;
		}
		List<PortalCustomDef> defList = portalCustomDefService.queryDef(def);
		res.setObject(defList);
		return res;
	}
	
}
